#define CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int* p = (int*)malloc(3 * 5 * sizeof(int));
	if (p == NULL)
	{
		perror("malloc");
		return EXIT_FAILURE;
	}
	int i = 0, j = 0;
	for (i = 0; i < 3; i++)
	{
		for (j = 0; j < 5; j++)
		{
			*((p + 3 * i) + j) = 3 * i + j;
		}
	}
	for (i = 0; i < 3; i++)
	{
		for (j = 0; j < 5; j++)
		{
			fprintf(stdout, "%d ", *((p + 3 * i) + j));
		}
	}

	free(p);
	p = NULL;
	return 0;
}